<template>
	<view class="order-manage">
		<!-- 顶部搜索及筛选区域 -->
		<view class="top-bar">
			<view class="cardform">
				<view class="order-item" v-for="(item, index) in evaluationlist" :key="index">
					<view class="top">
						<view style="padding-top: 30rpx">{{item.nickName}}</view>
						<view style="padding-top: 20rpx;"><u-button text="查看详情" @click="showDetail(item)" style="color: white;background-color: blueviolet;border-radius: 40rpx;width: 200rpx;"></u-button></view>
					</view>
					<view style="border-bottom: 1rpx red solid;margin-top: 20rpx;margin-bottom: 20rpx;">
					</view>
					<view>
						<view style="color: blueviolet;">订单编号：{{item.orderId}}</view>
						<view style="display: flex;">
							<view>综合评分：{{item.starRating}}</view>
							<view><u-rate  v-model="item.starRating" readonly></u-rate></view>
							
						</view>
						<view style="color: gray;">评价时间：{{item.evaluationTime.slice(0, 10)}}</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 新增：详情弹窗 -->
		<view class="modal-mask" v-if="showModal" @click="showModal = false">
			<view class="modal-container" @click.stop>
				<view class="modal-header">
					<text class="modal-title">评价详情</text>
					<text class="modal-close" @click="showModal = false">×</text>
				</view>
				<view class="modal-content">
<!-- 					<view class="modal-item">
						<text class="modal-label">评价ID：</text>
						<text class="modal-value">{{ currentDetail.evaluationId }}</text>
					</view> -->
					<view class="modal-item">
						<text class="modal-label">用户昵称：</text>
						<text class="modal-value">{{ currentDetail.nickName }}</text>
					</view>
<!-- 					<view class="modal-item">
						<text class="modal-label">用户ID：</text>
						<text class="modal-value">{{ currentDetail.userId }}</text>
					</view> -->
<!-- 					<view class="modal-item">
						<text class="modal-label">商户ID：</text>
						<text class="modal-value">{{ currentDetail.mId }}</text>
					</view> -->
					<view class="modal-item">
						<text class="modal-label">订单编号：</text>
						<text class="modal-value">{{ currentDetail.orderId }}</text>
					</view>
					<view class="modal-item">
						<text class="modal-label">综合评分：</text>
						<text class="modal-value">{{ currentDetail.starRating }}</text>
					</view>
					<view class="modal-item">
						<text class="modal-label">评价内容：</text>
						<text class="modal-value">{{ currentDetail.commentContent }}</text>
					</view>
					<view class="modal-item">
						<text class="modal-label">评价时间：</text>
						<text class="modal-value">{{ currentDetail.evaluationTime.slice(0, 10) }}</text>
					</view>
					<view class="modal-item">
						<text class="modal-label">更新时间：</text>
						<text class="modal-value">{{ currentDetail.updateTime }}</text>
					</view>
					<view class="modal-item" v-if="currentDetail.imgUrls">
						<text class="modal-label">评价图片：</text>
						<image :src="currentDetail.imgUrls" mode="widthFix" class="modal-image"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
			get,
			post,
			put
		} from '../../utils/request.js'
	export default {
		data() {
			return {
				evaluationlist:[
					{
					name:"张女士",
					evaluationid:"20210110831213",
					score:3,
					time:"2023-03-12 11-02"
				},
				{
					name:"张女士",
					evaluationid:"20210110831213",
					score:3,
					time:"2023-03-12 11-02"
				},
				],
				// 新增：弹窗控制变量
				showModal: false,
				currentDetail: {}
			}
		},
		methods: {
			// 新增：显示详情弹窗方法
			showDetail(item) {
				this.currentDetail = item;
				this.showModal = true;
			}
		},
		async onLoad() {
			console.log(uni.getStorageSync('merchant').id)
			const res=await get('/dev-api/system/evaluation_mm/list/mid/'+uni.getStorageSync('merchant').id,{})
			console.log(res)
			for(let i=0;i<res.length;i++){
				const user=await get('/dev-api/vehicle/user_m/'+res[i].userId,{})
				console.log(user.data)
				this.evaluationlist=res
				this.evaluationlist[i].nickName=user.data.nickName
			}
		}
	}
</script>

<style>
	.order-manage {
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	/* 顶部搜索及筛选 */
	.top-bar {
		padding: 10px;
		background-color: #2979ff;
		height: 200rpx;
	}
	.cardform {
		width: 90%;
		padding-left: 5%;
		padding-right: 5%;
		height: 900rpx;
		border-radius: 15rpx;
		padding-top: 15rpx;
	}
	.top{
		display: flex;
		gap: 270rpx;
	}
	.order-item {
		width: 90%;
		padding-left: 5%;
		padding-right: 5%;
		background-color: white;
		margin-bottom: 20rpx;
		border-radius: 25rpx;
	}

	/* 新增：弹窗样式 */
	.modal-mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 999;
	}
	.modal-container {
		width: 80%;
		max-width: 600rpx;
		background-color: white;
		border-radius: 20rpx;
		overflow: hidden;
	}
	.modal-header {
		padding: 30rpx;
		border-bottom: 1rpx solid #eee;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.modal-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}
	.modal-close {
		font-size: 40rpx;
		color: #999;
	}
	.modal-content {
		padding: 30rpx;
		max-height: 600rpx;
		overflow-y: auto;
	}
	.modal-item {
		display: flex;
		margin-bottom: 25rpx;
	}
	.modal-label {
		width: 200rpx;
		font-weight: bold;
		color: #666;
	}
	.modal-value {
		flex: 1;
		color: #333;
		word-break: break-all;
	}
	.modal-image {
		width: 300rpx;
		height: 300rpx;
		margin-top: 10rpx;
		border-radius: 10rpx;
	}
</style>
